#!/bin/bash

set -x

# dir="/mnt/yanyi/ceph/build"
# cd ${dir}

hostname=`hostname`

ib_str=`ip route |grep ib0 |grep src`
array=(${ib_str// / })
ib_ip=${array[${#array[@]}-1]}

echo $hostname
echo $ib_ip

# generate monmap，and save as /etc/ceph/monmap. Then register ins01 in monmap.
bin/monmaptool --create --clobber --add ${hostname} ${ib_ip}  --fsid 57077c8f-0a92-42e8-a82c-61198875a30e /etc/ceph/monmap
sleep 1

# create work dir of mon.ins01
bin/ceph-mon --mkfs -i ${hostname} --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
sleep 1

# start mon service
bin/ceph-mon -i ${hostname}
